#include"Delay.h"
#include <REGX52.H>
unsigned char r_k,tem;
unsigned char key()
{
	tem=r_k;
	r_k=0;
	return tem;
}
unsigned char key_f()
{
  unsigned char keynum=0;
	if(P3_1==0){keynum=1;}
	if(P3_0==0){keynum=2;}
	if(P3_2==0){keynum=3;}
	if(P3_3==0){keynum=4;}
	return keynum;
}

unsigned char key_loop()
{
	static unsigned char NOWSTAE,LASTSTAE;
	LASTSTAE=NOWSTAE;
	NOWSTAE=key_f();
	if(LASTSTAE==1&&NOWSTAE==0){r_k=1;}
	if(LASTSTAE==2&&NOWSTAE==0){r_k=2;}
	if(LASTSTAE==3&&NOWSTAE==0){r_k=3;}
	if(LASTSTAE==4&&NOWSTAE==0){r_k=4;}
	return r_k;
}